using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace Sanchay
{
    public partial class Form2 : Form
    {
        DashBoard m_dashboard;
        private BackgroundWorker m_bgWorker = new BackgroundWorker();
        public Form2(DashBoard dashboard)
        {
            m_dashboard = dashboard;
           
            InitializeComponent();

        }
       
        private void Form2_Load(object sender, EventArgs e)
        {

           
            //progressBar1.Value = 0;
            m_bgWorker.DoWork += new DoWorkEventHandler(m_bgWorker_DoWork);
            m_bgWorker.ProgressChanged += new ProgressChangedEventHandler(m_bgWorker_ProgressChanged);
            m_bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(m_bgWorker_RunWorkerCompleted);

            m_bgWorker.WorkerReportsProgress = true;
            m_bgWorker.WorkerSupportsCancellation = true;

            m_bgWorker.RunWorkerAsync();
        }
        void m_bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //m_dashboard.BackColor = Color.LightGray;
            //General objGeneral = new General();

            //bool isMailSent = objGeneral.SendEmail("db.mdf", "Sanchay-Database-Backup(" + DateTime.Now + ")", "ganesh.agrawal@sapple.co.in");
            //if (isMailSent == true)
            //{
            //    MessageBox.Show("Success");

            //}
            //else
            //{
            //    MessageBox.Show("Failed");
            //}
            //m_dashboard.BackColor = Color.White;
            Thread.Sleep(5000);
           
        }

        void m_bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
           //progressBar1.Value = e.ProgressPercentage;
        }

        void m_bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //bool success = (bool)e.Result;
            //if (success)
            //{
            //    MessageBox.Show("Success!");
            //}
            //else
            //{
               
              
            //    MessageBox.Show("Failure!");
            //}
            MessageBox.Show("Backup completed successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}